package com.umfwechat.core.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.aspectj.lang.JoinPoint;
import org.springframework.ui.ModelMap;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.context.request.WebRequestInterceptor;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.umfwechat.core.loggers.LoggersFactory;
import com.umfwechat.util.ActionUtil;
import com.umpay.operation.util.StringUtil;
import com.umpay.sp.util.DateTimesUtil;

/**
 * 简要日志输出拦截器
 */
public class MPSPLogInterceptor implements HandlerInterceptor{

	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		String time = DateTimesUtil.datetime14();
		String serverIp = ActionUtil.getMyIp();//获取本机IP
		String custIp = ActionUtil.getCustIp(request);//请求IP
		String uri = StringUtil.trim(request.getRequestURI());
		StringBuffer stringBuffer = new StringBuffer();
		stringBuffer.append(serverIp).append(",");
		stringBuffer.append(custIp).append(",");
		stringBuffer.append(uri).append(",");
		stringBuffer.append(time);
		LoggersFactory.MPSP_LOGGER().info(stringBuffer.toString());
		return true;
	}

	@Override
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
	}

	@Override
	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
	}



	

		
	
	
}
